<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateCmsSlideItemsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('cms_slide_items')) {
            Schema::create('cms_slide_items', function (Blueprint $table) {
                $table->id();
                $table->integer('slide_id')->comment('幻灯片ID,cms_slides.id');
                $table->string('image', 255)->comment('幻灯片图片');
                $table->string('url', 255)->nullable()->comment('幻灯片链接');
                $table->string('target', 10)->nullable()->comment('友情链接打开方式');
                $table->string('title', 50)->nullable()->comment('幻灯片名称');
                $table->string('description', 255)->default('')->comment('幻灯片描述');
                $table->text('content')->nullable()->comment('幻灯片内容');
                $table->float('order')->default(0)->comment('排序,值越大权重越大');
                $table->enum('status', ['show', 'hidden'])->default('show')->comment('状态,show:显示;hidden:隐藏');
                $table->json('more')->nullable()->comment('扩展信息');
                $table->softDeletes();
                $table->timestamps();
            });
            DB::statement("ALTER TABLE `cms_slide_items` comment '幻灯片子项表'");
        } 
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('cms_slide_items');
    }
}
